var db = require("./db");

module.exports = {

	createAgents: function(param, callback) {
		var sql = "";
		for (var i = 1; i < param.length; i++) {
			sql += "INSERT INTO `mmlink`.`t_agent` (`JOB_ID`, `PASS_WORD`, `BUSINESS`, `COUNTS`, `STATUS`, `ROLE`) VALUES ('" + param[i][1] + "', '" + param[i][2] + "', NULL, 5, 0,'" + param[i][5] + "');";
		}
		db.query(sql, callback);
	},

	selectAgents: function(type, callback) {

		db.query({
			sql: sql,
			values: null
		}, callback);
	},

	login: function(data, callback) {
		db.query({
			sql: "SELECT * FROM T_AGENT WHERE JOB_ID=? AND PASS_WORD=?",
			values: [data.name, data.pass]
		}, callback)
	},
	
	updateAgentInfo:function(param,callback){
		db.query({
			sql: "UPDATE T_AGENT_INFO SET ?=? WHERE JOB_ID=?",
			values: param
		}, callback)
	}


}